#ifndef QILIIMAGELOADER_H
#define QILIIMAGELOADER_H

#include <QObject>

class QPixmap;

class QiliImageLoader : public QObject
{
    Q_OBJECT

public:
    enum Error { BadURL, DataUnavailable, ParseFailed };
    Q_ENUM(Error);

    QiliImageLoader(const QString &url = QString(), bool loading = true, QObject *parent = nullptr);
    void load();

signals:
    void ready(const QPixmap &pixmap);
    void errorOccurred(Error error, const QString &reason);

public slots:
    void setUrl(const QString &url);

private:
    void onRawData(const QByteArray &data);
    QString mUrl;
};

#endif // QILIIMAGELOADER_H
